//
//  YDAWeekNewCell.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/21.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "YDAWeekNewCell.h"
#import "YDAWeekNewModel.h"


@interface YDAWeekNewCell()

/**
 白色背景
 */
@property (nonatomic, strong)UIView *bgView;

/**
 图片
 */
@property (nonatomic, strong)UIImageView *icon;


/**
 标题文本
 */
@property (nonatomic, strong)UILabel *titleLbl;

/**
 时间
 */
@property (nonatomic, strong)UILabel *dateLbl;


@end


@implementation YDAWeekNewCell

-(void)setModel:(YDAWeekNewModel *)model
{
    _model = model;
    
    self.bgView.frame = model.backFrame;
    self.icon.frame = model.imageFrame;
    self.titleLbl.frame = model.titleFrame;
    self.dateLbl.frame = model.timeFrame;
    
    
    [self.icon sd_setImageWithURL:[NSURL URLWithString:model.coverUrl] placeholderImage:[UIImage imageNamed:@"banner-bg"]];
    
    self.dateLbl.text = model.formateTime;
    self.titleLbl.attributedText = model.attrTitle;
    
    
    
    
}
+ (instancetype)cellWithTbaleview:(UITableView *)tableview
{
    static NSString *const aWeekNewCell = @"YDAWeekNewCell";
    
    YDAWeekNewCell *cell = [tableview dequeueReusableCellWithIdentifier:aWeekNewCell];
    if (cell == nil) {
        cell = [[YDAWeekNewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:aWeekNewCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor colorWithHexString:mainGray];
        self.contentView.backgroundColor = [UIColor colorWithHexString:mainGray];
        
        [self bgView];
        [self icon];
        [self titleLbl];
        [self dateLbl];
    }
    return self;
}


-(UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 4;
        _bgView.layer.masksToBounds = YES;
        [self.contentView addSubview:_bgView];
    }
    return _bgView;
}
-(UIImageView *)icon
{
    if (_icon == nil) {
        _icon = [UIImageView new];
        [self.contentView addSubview:_icon];
    }
    return _icon;
}

-(UILabel *)titleLbl
{
    if (_titleLbl == nil) {
        _titleLbl = [UILabel new];
        _titleLbl.numberOfLines = 0;
        _titleLbl.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        _titleLbl.textColor = [UIColor colorWithHexString:dark];
        _titleLbl.text = @"京东物流分拆融资20亿美元？我们来给刘强东估个价";
        [self.contentView addSubview:_titleLbl];
    }
    return _titleLbl;
}

-(UILabel *)dateLbl
{
    if (_dateLbl == nil) {
        _dateLbl = [UILabel new];
        _dateLbl.text = @"2018.02.26 12:30";
        _dateLbl.textColor = [UIColor colorWithHexString:battleshipGrey];
        _dateLbl.font = [UIFont systemFontOfSize:font10ScreenWRate * LKScreenW];
        [self.contentView addSubview:_dateLbl];
    }
    return _dateLbl;
}

@end
